package utils;


import utils.dataaccess.DBInterface;
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;



@WebListener
@ManagedBean(name="userSessionListener")
@ApplicationScoped
public class UserSessionListener implements HttpSessionListener{
    
    private static Integer currentConnections = 0;

    public int getCurrentConnections() {
        return currentConnections;
    }
    
    
    @Override
    public void sessionCreated(HttpSessionEvent se) {
        currentConnections++;
        DBInterface.increaseUserCounter();
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent se) {
        currentConnections--;
    }
   
}
